{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e0f88a0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "def search4vowels():\n",
    "    vowels = set('aeiou')\n",
    "    word = input(\"Provide a word to search for vowels:\")\n",
    "    found = vowels.intersection(set(word)) # 交集运算\n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7b416711",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:bobohuiiia\n",
      "a\n",
      "u\n",
      "i\n",
      "o\n"
     ]
    }
   ],
   "source": [
    "# 调用函数\n",
    "search4vowels()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3e49d58d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:aaaqqqwwwwee\n",
      "a\n",
      "e\n"
     ]
    }
   ],
   "source": [
    "search4vowels()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "36c77015",
   "metadata": {},
   "outputs": [],
   "source": [
    "def search4vowels():\n",
    "    \"\"\"Display any vowels found in an asked-for word.\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    word = input(\"Provide a word to search for vowels:\")\n",
    "    found = vowels.intersection(set(word)) \n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "2af0229d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:wohekdiy\n",
      "e\n",
      "i\n",
      "o\n"
     ]
    }
   ],
   "source": [
    "search4vowels()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "2ec0c877",
   "metadata": {},
   "outputs": [],
   "source": [
    "def search4vowels(word):\n",
    "    \"\"\"Display any vowels found in a supplied word.\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    # 不再有这行\"input\"函数调用 word = input(\"Provide a word to search for vowels:\")\n",
    "    found = vowels.intersection(set(word)) \n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "37c9186e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# python创建函数并不限制为只有一个参数，可以有任意多个参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "7665a0af",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "search4vowels() missing 1 required positional argument: 'word'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-17-c5308b945af7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0msearch4vowels\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: search4vowels() missing 1 required positional argument: 'word'"
     ]
    }
   ],
   "source": [
    "search4vowels()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86669e45",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
